package managesystem;

import java.io.Serializable;
import java.util.Iterator;
import java.util.Collection;


public class Buddy implements Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String firstname;
	private String lastname;
	
	@SuppressWarnings("unused")
	private Buddy(){}; // een constructor zonder parameters moet bestaan om de class als entiteit te registreren voor objectify
	
	public Buddy(String firstname, String lastname){
		this.firstname = firstname;
		this.lastname = lastname;
	}

	
	/**
	 * geeft de voornaam van de buddy
	 * @return firstname
	 */
	public String getFirstname() {
		return firstname;
	}

	/**
	 * geeft de achternaam van de buddy
	 * @return lastname
	 */
	public String getLastname() {
		return lastname;
	}
	
	public int getId(){
		return this.hashCode();
	}
	
	public static boolean controlBuddyList(Collection<Buddy> buddylist, Buddy buddy){
		boolean found = false;
		Iterator<Buddy> iterator = buddylist.iterator();
		while(iterator.hasNext()){
			Buddy buddyit = iterator.next();
			if(buddy.getFirstname().equals(buddyit.getFirstname()) && buddy.getLastname().equals(buddyit.getLastname())){
				found = true;
			}
		}
		return found;
		
	}
	
}
